home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Technology Seed / ADC Seed CD - July 1999.toast / Carbon SDK 1.0d10c3 / Sample Code / AppearanceSample / BaseDialog.cp < prev    next >
Encoding:
Text File  |  1999-05-01  |  2.2 KB  |  130 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        BaseDialog.cp
  3.  
  4.     Contains:    Base class for a dialog.
  5.  
  6.     Version:    Appearance 1.0 SDK
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Edward Voas
  13.  
  14.         Other Contact:        7 of 9, Borg Collective
  15.  
  16.         Technology:            OS Technologies Group
  17.  
  18.     Writers:
  19.  
  20.         (edv)    Ed Voas
  21.  
  22.     Change History (most recent first):
  23.  
  24.            $Log: BaseDialog.cp,v $
  25.            Revision 1.4  1998/09/04 19:48:29  christ
  26.            Do not reference fWindow before we retrieve it from the dialog.
  27.            
  28.  
  29.          <1>     9/11/97    edv        First checked in.
  30. */
  31.  
  32. #include "AppearanceSamplePrefix.h"
  33.  
  34. #include <Dialogs.h>
  35. #include "BaseDialog.h"
  36.  
  37. BaseDialog::BaseDialog()
  38. {
  39.     fDialog = NULL;
  40. }
  41.  
  42. BaseDialog::BaseDialog( SInt16 resID )
  43. {
  44.     fDialog = GetNewDialog( resID, NULL, (WindowPtr)-1L );
  45.     if ( fDialog )
  46.     {
  47.         fWindow = GetDialogWindow( fDialog );
  48.         fPort = GetWindowPort( fWindow );
  49.  
  50.         SetWindowKind( fWindow, 2000 );
  51.         SetWRefCon( fWindow, (long)this );
  52.     }
  53.     else
  54.     {
  55.         // •••check for errors and do something real
  56.        ExitToShell();
  57.     }
  58. }
  59.  
  60. BaseDialog::~BaseDialog()
  61. {
  62.     if ( fWindow )
  63.     {
  64.         DisposeDialog( fDialog );
  65.         fWindow = nil;
  66.     }
  67. }
  68.  
  69. void
  70. BaseDialog::Update( EventRecord& event )
  71. {
  72.     DialogPtr        dialog;
  73.     SInt16            itemHit;
  74.  
  75.     SetWindowKind( fWindow, dialogKind );
  76.     DialogSelect( &event, &dialog, &itemHit );
  77.     SetWindowKind( fWindow, 2000 );
  78. }
  79.  
  80. void
  81. BaseDialog::Activate( EventRecord& event )
  82. {
  83.     DialogPtr        dialog;
  84.     SInt16            itemHit;
  85.     
  86.     SetWindowKind( fWindow, dialogKind );
  87.     DialogSelect( &event, &dialog, &itemHit );
  88.     SetWindowKind( fWindow, 2000 );
  89. }
  90.  
  91. void
  92. BaseDialog::Deactivate( EventRecord& event )
  93. {
  94.     DialogPtr        dialog;
  95.     SInt16            itemHit;
  96.     
  97.     SetWindowKind( fWindow, dialogKind );
  98.     DialogSelect( &event, &dialog, &itemHit );
  99.     SetWindowKind( fWindow, 2000 );
  100. }
  101.  
  102. void
  103. BaseDialog::HandleClick( EventRecord& event )
  104. {
  105.     DialogRef        dialog;
  106.     SInt16            itemHit;
  107.     
  108.     if ( DialogSelect( &event, &dialog, &itemHit ) )
  109.     {
  110.         HandleItemHit( itemHit );
  111.     }
  112. }
  113.  
  114. void
  115. BaseDialog::HandleKeyDown( EventRecord& event )
  116. {
  117.     DialogPtr        dialog;
  118.     SInt16            itemHit;
  119.     
  120.     SetWindowKind( fWindow, dialogKind );
  121.     DialogSelect( &event, &dialog, &itemHit );
  122.     SetWindowKind( fWindow, 2000 );
  123. }
  124.  
  125.  
  126. void
  127. BaseDialog::HandleItemHit( short /*itemHit*/ )
  128. {
  129. }
  130.